package com.xie.authority_system.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xie.authority_system.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author XIEJINGCHENG
 * @description 针对表【sys_user(用户表)】的数据库操作Mapper
 * @createDate 2024-01-08 14:45:36
 * @Entity com.xie.authority_system.entity.User
 */
public interface UserMapper extends BaseMapper<User> {
    /**
     * 删除用户角色关系
     *
     * @param userId
     * @return
     */
    @Delete("delete from sys_user_role where user_id = #{userId}")
    int deleteUserRole(Long userId);


    int saveUserRole(@Param("userId") Long userId, @Param("roleIds") List<Long> roleIds);

    @Select("select role_id from sys_user_role where user_id = ${userId}")
    List<Long> getUserRole(Long userId);
}




